<template>
  <div>
    <div>
      <div class="w-24">
        <u-button type="primary" text="登出" class="" @click="logout"></u-button>
      </div>
    </div>
    <div class="">
      <div class="!bg-blue-500 w-1/4">
        位置：{{localObj}}
      </div>
      <div class="p-2">
        <u-button type="primary" text="获取当前位置" class="bg-red-500" @click="getLocal"></u-button>
      </div>
      <u-cell-group>
        <u-cell :title="item.tagName" v-for="(item,index) in list" class=" " :key="index" :isLink="true">
          <div slot=title>
            <div>
              ({{index}})-{{item.tagName}}
            </div>
            <div>
              {{item.declareTime}}
            </div>
          </div>
        </u-cell>
      </u-cell-group>
      <u-loadmore :status="status" dashed line />
    </div>

    <zk-tab-bar></zk-tab-bar>
  </div>
</template>

<script>
  import goodsApi from '@/api/goods';
  import loginApi from '@/api/common';
  import {
    mixList
  } from '@/utils/flowList';
  import store from '@/store/index.js'; //需要引入store
  export default {
    mixins: [mixList],
    components: {},

    data() {
      return {
        current: 0,
        value1: 0,
        proportionvc: 0.5,
        handleHeight: 20,
        localObj:''
      };
    },
    computed: {
      username() {
        return store.state.zk_token
      }
    },
    onShow() {
      this.getList()
    },
    methods: {
      getLocal() {
        let _this  = this
        console.log(111)
        uni.getLocation({
          type: 'wgs84',
          success: function(res) {
            _this.localObj = res.longitude;
            console.log('当前位置的经度：' + res.longitude);
            console.log('当前位置的纬度：' + res.latitude);
          },
          fail:function(res){
            console.log('失败：' + res);
          },
          complete:function(res){
            console.log('complete：' + res);
          }
        })
        // uni.chooseLocation({
        // 	success: function (res) {
        // 		console.log('位置名称：' + res.name);
        // 		console.log('详细地址：' + res.address);
        // 		console.log('纬度：' + res.latitude);
        // 		console.log('经度：' + res.longitude);
        // 	}
        // });
        // console.log(111)
      },
      logout() {
        loginApi.logout()
      },
      getList(isRefresh) {
        goodsApi.list({
          ...this.pageOption,
          // queryType: 2
        }).then((res) => {
          // this.list = res.list
          this.mixList(res, isRefresh)
        })
      }

    },
  };
</script>

<style lang="less">

</style>
